//
//  GameDetailViewController.m
//  RecreationGame
//
//  Created by appying_wxj on 15/1/22.
//  Copyright (c) 2015年 appying_wxj. All rights reserved.
//

#import "GameDetailViewController.h"
#import "PictureViewController.h"

@interface GameDetailViewController ()<UIWebViewDelegate,UIAlertViewDelegate>{
    NSMutableArray *_fileArray;
    UIWebView *_webView;
}

@end

@implementation GameDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initGameDetailUI];
    NSLog(@"-----获取到的文件有-----%@",self.fileString);
}
-(void)initGameDetailUI{

    self.view.backgroundColor = [UIColor whiteColor];
    [self.leftButton addTarget:self action:@selector(leftButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    
    // 底部的按钮 （玩起来）
    UIButton *bottomButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [bottomButton setTitle:@"玩起来" forState:UIControlStateNormal];
    bottomButton.frame = CGRectMake(0, kHeight-80, kwidth, 80);
    bottomButton.backgroundColor = [UIColor colorWithRed:0.9 green:0.62 blue:0.67 alpha:1];
    [bottomButton addTarget:self action:@selector(bottomButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:bottomButton];
    
    _webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 64, kwidth, kHeight-120)];
    _webView.delegate = self;
    NSURL *url=[NSURL URLWithString:self.fileString];
    NSURLRequest *request=[[NSURLRequest alloc] initWithURL:url];
    [_webView loadRequest:request];
    [self.view addSubview:_webView];
    
}
#pragma mark=====UIWebView Delegate
- (void) webViewDidStartLoad:(UIWebView *)webView
{
    NSLog(@"webViewDidStartLoad");
}
- (void) webViewDidFinishLoad:(UIWebView *)webView
{
    NSLog(@"webViewDidFinishLoad");
}
- (void) webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    NSLog(@"didFailLoadWithError:%@", error);
}
// 玩起来的按钮的点击事件
-(void)bottomButtonClick:(UIButton *)sender{
//    PictureViewController *picture = [[PictureViewController alloc] init];
//    [self presentViewController:picture  animated:YES completion:nil];

//    //状态提示框
//    _greyView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kwidth, kHeight)];
//    _greyView.backgroundColor =[UIColor colorWithRed:70.0 / 255.0 green:70.0 / 255.0 blue:70.0 / 255.0 alpha:0.5];
//    [self.view addSubview:_greyView];
//    
//    UIView *alertView = [[UIView alloc]initWithFrame:CGRectMake(10, (kHeight-100)/2, 300, 100)];
//    alertView.backgroundColor = [UIColor colorWithRed:0.94 green:0.94 blue:0.94 alpha:0.8];
//    [alertView.layer setMasksToBounds:YES];
//    [alertView.layer setCornerRadius:10.0]; //设置矩形四个圆角半径
//    [alertView.layer setBorderWidth:1.0];
//    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
//    CGColorRef colorref = CGColorCreate(colorSpace,(CGFloat[]){ 0, 0, 0, 0 });
//    [alertView.layer setBorderColor:colorref];//边框颜色
//    
//    UILabel *hintLabel = [[UILabel alloc] init];
//    hintLabel.frame = CGRectMake(10, 20, alertView.frame.size.width-20, 20);
//    hintLabel.text = @"大家一起来合影";
//    hintLabel.textColor = [UIColor grayColor];
//    hintLabel.backgroundColor = [UIColor clearColor];
//    hintLabel.textAlignment = NSTextAlignmentCenter;
//    
//    
//    NSArray *titleArray = [NSArray arrayWithObjects:@"好，玩起来",@"不，直接玩", nil];
//    for (int g = 0; g<titleArray.count; g++) {
//        UIButton *twoButton = [UIButton buttonWithType:UIButtonTypeCustom];
//        twoButton.frame = CGRectMake(10+g*((alertView.frame.size.width-30)/2+10), 40, (alertView.frame.size.width-30)/2, 40);
//        twoButton.backgroundColor = [UIColor colorWithRed:0.9 green:0.62 blue:0.67 alpha:1];
//        [twoButton setTitle:[titleArray objectAtIndex:g] forState:UIControlStateNormal];
//        [twoButton addTarget:self action:@selector(twoButtonClick:) forControlEvents:UIControlEventTouchUpInside];
//        twoButton.tag = 100+g;
//        [alertView addSubview:twoButton];
//        
//    }
//    
//    [alertView setHidden:YES];
//    [UIView animateWithDuration:0.1 animations:^{
//        [alertView setHidden:NO];
//        alertView.frame=CGRectMake(10, (kHeight-100)/2, 300, 100);
//        [_greyView addSubview:alertView];
//        [alertView addSubview:hintLabel];
//    }completion:^(BOOL finished) {
//    }];
    
    UIAlertView *hintAlertView = [[UIAlertView alloc] initWithTitle:@"大家一起来合影" message:nil delegate:self cancelButtonTitle:@"不，直接玩" otherButtonTitles:@"好，玩起来", nil];
    hintAlertView.delegate = self;
    [hintAlertView show];

}
//// 玩起来 和 不，直接玩  的点击按钮
//-(void)twoButtonClick:(UIButton *)sender{
//    
//}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    switch (buttonIndex) {
        case 0:{
            NSLog(@"点击了--------不，直接玩");
        }
            break;
        case 1:{
            NSLog(@"点击了--------好，玩起来");
//            UIAlertView *pictureAlert=[[UIAlertView alloc] initWithTitle:@"请选择图片来源" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"拍照",@"从手机相册选择", nil];
//            [pictureAlert show];
            PictureViewController *picture = [[PictureViewController alloc] init];
            [self presentViewController:picture  animated:YES completion:nil];
        }
            
            break;
            
        default:
            break;
    }
}
// 刚刚收到宝贝 就迫不及待的过来评价了 宝贝真的很好，包装很正，查了一下，是正品 很是惊喜 大爱哦！！！！
// 迫不及待的也试用了一下 清洁效果特好而且不紧绷，而且还有淡淡香味，绝对买值了。

-(void)leftButtonClick:(UIButton *)sender{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
